Skip to content

feat(session-flow): record the next tool after each hook-block denial - #9174

Merged
kyle-sexton merged 2 commits into
mainfrom
work-resolve-issue/issue-5668-39847721143-1
Oct 23, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
work-resolve-issue/issue-5668-39847721143-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Refs: #5668

Summary

Opened by the work-resolve-issue lane. The run's own summary:

The friction scanner now records next_tool and next_ok on each hook-block denial, and friction.py mine tallies them per event key and side in JSON and markdown. This builds only the measurement field; the accept-or-briefing choice and the re-measure stay with #8986, so the PR does not close the issue.

Not verified

  • pytest for test_friction_scan.py and test_friction.py was not run in this run (the lane allowed no interpreter command); the issue's checks are left to the PR's CI
  • The owner's accept-or-briefing choice, running audit-friction on both machines and the re-measure are split to #8986
  • The tally reads stored events, which are capped at 200 per session, so a session past the cap contributes only the events it kept; sessions collected before this change carry no next_tool
  • Changes are left uncommitted in the working tree as the runner instructs

Fix

  • plugins/session-flow/skills/audit-sessions/scripts/friction_scan.py: hook-block denial events get next_tool (next tool_use in the same file, None if none) and next_ok (that call's result), plus a key field matching the counts key
  • plugins/session-flow/skills/audit-friction/scripts/friction.py: aggregate() tallies next_tool per (side, key) with ok/failed/unknown counts; render_mine adds a markdown table
  • plugins/session-flow/skills/audit-sessions/scripts/tests/test_friction_scan.py: cases for next call Write, repeated shell form, no next call, per-file and hook-only scope
  • plugins/session-flow/skills/audit-friction/scripts/tests/test_friction.py: fixture-based mine test and a synthetic aggregate test
  • .changes/session-flow/feat-5668-next-tool-after-hook-block-7c2e9a41.md: minor changelog fragment (written by hand: the fragment helper needs a branch name and HEAD is detached)

Verification

The runner ran each check from the base copy against c219fed:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

Left out: the items under Not verified.

Related

#5668

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review needs no new review of dc31f080e571942cc45a7982c6a6f874b37aca30: no file of this pull request changed since the review of c219fed.

Security review: PR #9174 (head c219fed)

Result: no security issues found.

The PR adds next_tool / next_ok tracking to hook-block denial events in the session-flow friction scanner (friction_scan.py), tallies them in friction.py mine, and adds tests and a changelog fragment. It changes no plugin manifest, workflow, hook, or standing instruction, so the manifest checks and the instruction-surface lens do not apply. The protected-class register was not consulted for that reason.

  • Untrusted transcript text: next_tool is added to SCRUBBED_FIELDS, so it goes through the redactor before storage. The new stored key goes through scrub.key(...). No new secret or path leak.
  • Output rendering: The markdown table escapes | in the key and the tool name. A tool name with a newline could distort the table layout. That affects only a local operator report and has no exploit path, so it is not reported.
  • Execution surface: There is no new command execution, file write, network access, deserialization, or path handling. The change only adds counters over parsed JSON.
  • Tests: The new tests build fixtures in memory and touch no real transcripts.

No inline comments were posted.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

claude-review needs no new review of dc31f080e571942cc45a7982c6a6f874b37aca30: no file of this pull request changed since the review of c219fed.

Code review: no findings

I read all 5 changed files in the diff, the PR context, and the surrounding friction_scan.py and friction.py code. I found nothing a careful reviewer would block on.

What I checked

  • Scanner logic. I traced next_tool and next_ok through _assistant, _tool_result and start_file. These cases all behave as intended:
    • A retry that is itself a hook denial: the first denial gets next_ok=False and the retry opens a new pending event.
    • No later call: both fields stay None.
    • A file boundary: pending denials are cleared, so nothing carries across files.
    • Non-hook denials: they never get the fields.
  • Join key. block() stores key = scrub.key(event_key(event)). scrub.keys() builds the counts keys with the same key() call, so the key aggregate() joins on matches the counts key, including after redaction.
  • Aggregation and rendering. The next_tool tally is added to a row only when the key has hook events, and render_mine escapes | in the key and tool name. The per-session event cap and the older-sessions limitation are stated in the PR and the changelog fragment.
  • Changelog fragment. bump: minor fits a new field and a new output table.
  • Closing issue. The PR uses Refs: #5668 and closes nothing, so there are no acceptance criteria to check.
  • Path-scoped rules. The only matching rule is ruff-pin.md (**/*.py); it governs how to lint, not what the code does.
  • Plugin manifests. The diff changes no manifest.

Not verified: I could not run pytest or ruff here because the sandbox refused those commands. Whether the new tests pass is unconfirmed; my reading of the test fixtures and helpers found nothing that would fail them. The PR's own verification claims are author-reported and I did not independently confirm them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant